package com.fjh.security.easy.starter.config;

import com.fjh.security.easy.starter.userdetails.CustomUser;
import lombok.Data;
import org.springframework.boot.autoconfigure.session.StoreType;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 配置参数
 *
 * @author fanjh37
 * @since 2023/2/11 10:09
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "security-easy")
public class EasyPropertiesConfig implements Serializable {

    /**
     * session 配置
     */
    private EasySession session;

    /**
     * 忽略路径
     */
    private String[] ignoreUrl;

    /**
     * 登录方式
     */
    private List<String> loginType = new ArrayList<>();

    /**
     * 锁定时间
     */
    private EasyLock lock;
    /**
     * 登录和鉴权
     */
    private EasyAuth userDetails;

    /**
     * 图形验证码
     */
    private EasyCaptcha captcha;

    private RememberMe rememberMe;


    @Data
    public static class EasyLock {
        private int timeOut = 60;
        private int failTime = 3;
    }


    @Data
    public static class EasyCaptcha {
        private Long timeOut = 600L;
    }

    @Data
    public static class EasyAuth {
        private StoreType storeType;
        private String usersByUsernameQuery;
        public String authoritiesByIdQuery;
        private List<CustomUser> users;
    }

    @Data
    public static class EasySession {
        /**
         * 请求头名字
         */
        private String headerName;
        private StoreType storeType;
        private boolean cookieType = true;
        private Long timeOut;
    }

    @Data
    public static class RememberMe {

        private String cookieName = "remember-me";

        private int timeOut = 600;
        //jdbc memory
        private StoreType storeType;

    }

}
